<?php

namespace bc\service\gene;

use bc\service\base\Service;
use bc\model\OrderbindMode;
use bc\model\UserreportModel;
use bc\model\ReportModel;
use bc\model\order\report\TemplateModel;

class FpService extends Service
{
	/**
	 * 
	 * @var OrderbindMode $model
	 */
	protected $model;
	
	/**
	 * 
	 */
	public function __construct()
	{
		$this->model = new OrderbindMode ();
	}
	
	/**
	 * 
	 * @param string $bind_no
	 * @return array
	 */
	public function getReportTemplate($bind_no)
	{
		$reportM = new ReportModel ();
		// 根据bind_no获取产品id
		$OrderbindM = new OrderbindMode ();
		//$OrderbindM->columns = 'bc_order_bind.user_id as ouser_id,bc_order_bind.product_id as oproduct_id';
		$OrderbindD = $OrderbindM->getRowP ( [ 
				'bind_no' => $bind_no 
		] );
		$user_id = $OrderbindD['user_id'];
		$product_id = 2;//肥胖上产品id
		$reportinfo = $reportM->getReportInfoTemp ( $user_id, $bind_no, $product_id );
		
		$templateModel = new TemplateModel();
		
		$template = $templateModel->getRowById(1);
		
		if($reportinfo['report_1_value'] >= 0.8 && $reportinfo['report_1_value'] <= 1.0)
		{
			$template = $templateModel->getRowById(2);
		}
		else if($reportinfo['report_5_value'] >= 0 && $reportinfo['report_5_value'] <= 0.49)
		{
			$template = $templateModel->getRowById(3);
		}
		else if($reportinfo['report_4_value'] >= 0 && $reportinfo['report_4_value'] <= 0.39)
		{
			$template = $templateModel->getRowById(4);
		}
		
		return $template['image'];
	}
}

